<template>
<layout-empty>
  <view class="pm-approval-bg">
    <view class="bg-img"></view>
  </view>
  <view class="pm-approval-container">
    <view class="pi-navbar-box">
      <view class="pi-navbar-left flex flex-row align-center">
        <uni-icons @click="gotoPreRoute" color="#fff" type="left" size="24"></uni-icons>
      </view>
      <view class="pi-navbar-title flex-grow-1">
        {{ formName || '项目详情' }}
      </view>
      <view class="pi-navbar-right flex-shrink-0 flex flex-row align-center">
        <view class="process-icon-box flex flex-row align-center">
          <iconfont color="#fff" name="icon-xiangmu"></iconfont>
          项目
        </view>
      </view>
    </view>
    <view v-if="ProjDetailComponent" class="pm-approval__body">
      <proj-detail-component ref="ProjDetailRef" />
    </view>
    <view v-else class="pm-approval__body">
      <not-promise />
    </view>
  </view>
</layout-empty>
</template>

<script setup lang="ts">
import LayoutEmpty from "@/layouts/empty.vue";
import {gotoPreRoute} from "@/utils";
import {usePmMenuStore} from "@/stores";
import viewComponents from "@/utils/registerViewModules";
import NotPromise from "@/components/error/NotPromise/index.vue";

const ProjDetailComponent = shallowRef<Component>(null);
const {menuMap} = usePmMenuStore()

const ProjDetailRef = ref();
const formName = ref<string>(null);
onLoad((query) => {
  const componentName = query['component_name'];
  ProjDetailComponent.value = menuMap[componentName] && viewComponents[`/src/views/${menuMap[componentName].component}.vue`]
  console.log(menuMap[componentName])
  formName.value = menuMap[componentName] && menuMap[componentName].name
})
</script>

<style scoped lang="scss">
@import 'src/styles/bg/todoBg';

.pm-approval-bg {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  background-color: #EDF4FC;

  .bg-img {
    width: 100%;
    height: 100%;
    background-image: $--oa-todo-bg;
    background-size: 100% auto;
    background-repeat: no-repeat;
    background-position: top center;
  }
}

.pm-approval-container {
  position: relative;
  z-index: 9;
  height: 100%;
  box-sizing: border-box;

  .pi-navbar-box {
    position: relative;
    height: 90rpx;
    padding: 0 40rpx;
    box-sizing: border-box;
    line-height: 90rpx;
    text-align: center;

    .pi-navbar-left {
      position: absolute;
      left: 40rpx;
      top: 0;
      height: 100%;
    }

    .pi-navbar-title {
      color: #fff;
      font-size: 18px;
      font-weight: 500;
    }

    .pi-navbar-right {
      position: absolute;
      right: 40rpx;
      top: 0;
      height: 100%;
      color: #fff;
      line-height: normal;

      .process-icon-box {
        background: rgba(255, 255, 255, 0.05);
        box-sizing: border-box;
        border: 1px solid rgba(255, 255, 255, 0.5);
        border-radius: 4px;
        font-size: 14px;
        padding: 4rpx 12rpx;

        .process-icon {
          width: 20rpx;
          height: 20rpx;
        }
      }
    }
  }

  .pm-approval__body {
    position: relative;
    height: calc(100% - 90rpx);
    overflow-x: hidden;
    overflow-y: auto;
  }
}
</style>
